package com.example.gw_back_end.config;

import io.minio.MinioClient;
import io.minio.admin.MinioAdminClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
@ConfigurationProperties(prefix = "minio")   // 根据prefix和属性名注入配置的信息
public class MinioConfig {
    private String endpoint;
    private String accessKey;
    private String secretKey;
    private String tempBucketName;
    private String GWBucketName;

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
    }

    @Bean
    public MinioAdminClient minioAdminClient() {
        return MinioAdminClient.builder()
                .endpoint(endpoint)
                .credentials(accessKey, secretKey)
                .build();
    }
}

